// FileDropTargetWindow.cpp: implementation of the FileDropTargetWindow class.
//
//////////////////////////////////////////////////////////////////////
#include "Ketonal.h"
#include "FileDropTargetWindow.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

FileDropTargetWindow::FileDropTargetWindow(Ketonal *_parent, KetonalConfig *_config)
{
	parent = _parent;
	config = _config;

	targetComponent = new FileDropTargetComponent(_config);
	addAndMakeVisible (targetComponent);

	setAlwaysOnTop (true);   
	addToDesktop (ComponentPeer::windowIsTemporary);
}

FileDropTargetWindow::~FileDropTargetWindow()
{
}

bool FileDropTargetWindow::isInterestedInFileDrag (const StringArray &files)
{
	return (true);
}

void FileDropTargetWindow::fileDragEnter (const StringArray &files, int x, int y)
{
	dropReady = true;
	targetComponent->mouseOver();
	setMouseCursor (MouseCursor::CopyingCursor);
}

void FileDropTargetWindow::fileDragMove (const StringArray &files, int x, int y)
{
}

void FileDropTargetWindow::fileDragExit (const StringArray &files)
{
	targetComponent->mouseOut();
	dropReady = false;
}

void FileDropTargetWindow::filesDropped (const StringArray &files, int x, int y)
{
	config->setRunning(true);
	dropReady = false;
	targetComponent->uploadFiles (files);

	parent->filesDropped (files, x, y);
}

bool FileDropTargetWindow::isDropReady()
{
	return (dropReady);
}

bool FileDropTargetWindow::isRunning()
{
	return (config->getRunning());
}

void FileDropTargetWindow::paint (Graphics &g)
{
	g.fillAll (Colours::white.withAlpha(0.0f));
}

void FileDropTargetWindow::resized()
{
	targetComponent->setBounds (0,0,128,128);
}
